home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Shareware World
/
Utilities
/
Text Processing
/
Alpha
/
Tcl
/
Modes
/
applescriptMode.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
3KB
|
85 lines
#############################################################################
# AppleScript.tcl
# John Sarapata
# sarapata_john@jpmorgan.com
#
# Installing:
# Put AppleScript.tcl in your Usercode folder
# Put the following line in userstartup.tcl:
# source $HOME:Tcl:Usercode:AppleScript.tcl
#
# Description:
# This file implements an AppleScript mode, for people who wish Script
# Editor had complex functions like search and replace. Currently, it
# only supports color editing and function finding, but I may extend it.
#
# I have not found a way to distinguish function definitions from
# on error constructs, so I assume that any "on name" statements at
# the beginning of the line are definitions. Script Editor saves files
# in this format, so you will only need to be careful when creating
# functions in Alpha.
#############################################################################
if {$startingUp} {
addMode Scrp dummyScrp {*.script} { }
return
}
#===============================================================================
# Set up the mode variables
newModeVar Scrp elecRBrace {0} 1
newModeVar Scrp electricSemi {0} 1
newModeVar Scrp elecLBrace {0} 1
newModeVar Scrp electricTab {0} 1
newModeVar Scrp wordWrap {0} 1
newModeVar Scrp autoMark {0} 1
newModeVar Scrp prefixString {--} 0
newModeVar Scrp leftFillColumn {3} 0
newModeVar Scrp funcExpr {^(ON)[ \t]+(\w+)} 0
newModeVar Scrp wordBreak {\w+} 0
newModeVar Scrp wordBreakPreface {\W} 0
proc dummyScrp {} {}
#===============================================================================
# Set up comments and keywords
set scriptKeyWords {
on end error global local return it me pi result space tab
close copy count data size delete duplicate exists get launch
make move open print quit run save in of is after before
div mod and not or start starts begin begins end ends contains
does equal equals greater less than as reference
set try
tell if repeat else then times while until with by
considering ignoring timeout transaction script property prop
first second third fourth fifth sixth seventh eighth ninth tenth
last front back middle every some from to through thru
}
regModeKeywords -e {--} -b {\(*} {*\)} -c red -k blue Scrp $scriptKeyWords
unset scriptKeyWords
#===============================================================================
# File Marking
proc ScrpMarkFile {} {
global ScrpmodeVars
set pos 0
while {![catch {search -f 1 -r 1 -m 0 -i 1 $ScrpmodeVars(funcExpr) $pos} res]} {
set start [lindex $res 0]
set end [lindex $res 1]
set text [lindex [getText $start $end] 1]
set pos $end
set inds($text) "$start $end"
}
if {[info exists inds]} {
foreach f [lsort [array names inds]] {
setNamedMark $f [lineStart [lineStart [lindex $inds($f) 0]] - 1] [lindex $inds($f) 0] [lindex $inds($f) 1]
}
}
}